#ifndef __DBROLE_CREATE_SUCCESSSENDER_H__
#define __DBROLE_CREATE_SUCCESSSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../DBServer.h"
#include "dbserver.pb.h"
#include "../../Sender/DBServerSender.h"

/**
*@file       DBRole_Create_SuccessSender.h
*@brief      send message DBRole_Create_Success
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/28
*/

///message wrapper
class msgDBRole_Create_Success
{
public:
    static const int MessageId = DBRole_Create_Success;
    //TODO
    pnSessionHandle    SessionId;
    CreateRoleSuccess  MsgContent;
    ///@brief    constructor
    msgDBRole_Create_Success(int session_id, int login_code, const std::string& role_code, const std::string& role_name, int level, int job_type, int world_id, int gender, int graphics):
    SessionId(session_id)
    {
        MsgContent.set_logincode(login_code);

        RoleInfoDigest* digest = MsgContent.mutable_roledigest();
        digest->set_rolecode(role_code);
        digest->set_rolename(role_name);
        digest->set_rolelevel(level);
        digest->set_jobtype(job_type);
        digest->set_worldid(world_id);
        digest->set_gender(gender);
        digest->set_graphicsid(graphics);
    }
};

class HandleDBRole_Create_Success
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of DBRole_Create_Success
    ///retval     void
    static void HandleMessage(msgDBRole_Create_Success* msg)
    {
        //TODO
        //Main Message:  msgDBServer
        msgDBServer mainMsg(msg->SessionId, msgDBRole_Create_Success::MessageId, ProtoNet<CreateRoleSuccess>::IntoBytes(msg->MsgContent));
        gwMessagePort::ProcessMessage(&mainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgDBRole_Create_Success, HandleDBRole_Create_Success);

#endif
